//
//  LoginViewController.m
//  RacLogin
//
//  Created by HB on 2017/10/16.
//  Copyright © 2017年 com.comzenz-service. All rights reserved.
//

#import "LoginViewController.h"
#import "BaseUse.h"
#import "LoginVm.h"

@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *pwdField;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@property (nonatomic, strong) LoginVm *loginVm;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _loginVm = [[LoginVm alloc] init];
    
    RAC(_loginVm,name) = _nameField.rac_textSignal;
    RAC(_loginVm,pwd) = _pwdField.rac_textSignal;
    
    RAC(_loginBtn,enabled)  = _loginVm.loginEnableSignal;
    
    [[_loginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        [[_loginVm.loginCommand execute:nil] subscribeNext:^(id  _Nullable x) {
            NSLog(@"请求到的数据是：===》 %@", x);
        }];
    }];
    
    
    // Do any additional setup after loading the view.
}

- (IBAction)loginAction:(id)sender {
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
